<include file="Public:header" />
<link rel="stylesheet" href="/Plugin/lightbox2/dist/css/lightbox.min.css">
{:W('Navigation')}
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">个人资料</div>
		<div class="row-table-body">
			<form class="form-horizontal " action="{:U('core/user/editinfo')}" enctype="multipart/form-data" method="post">
				<input type="hidden" name="user_id" value="{$user['user_id']}"/>
				
				<p class="form-title">基本信息&nbsp;&nbsp;<a href="javascript:history.go(-1);">返回</a></p>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-3">
						<if condition="session('?admin')"><input type="text" name="name" class="form-control" value="{$user['name']}"><else />{$user.name}</if><span class="color-red">*唯一</span>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">姓　名</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="nickname" value="{$user['nickname']}"><span class="color-red">*</span>
					</div>
				</div>
				<if condition="session('?admin')">
					<div class="form-group" id="password">
						<label for="name" class="col-sm-2 control-label">密码</label>
						<div class="col-sm-3">
							<input class="form-control" type="text" name="password">
						</div>
						<span class="color-red col-sm-3">为空则为不改</span>
					</div>
				</if>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">用户类别</label>
					<div class="col-sm-3">
						<if condition="session('?admin')">
						<select class="form-control" name="category_id" id="category_id">
							<option value="0" <if condition="0 eq $user['category_id']">selected = "selected"</if>>员工</option>
							<option value="1" <if condition="1 eq $user['category_id']">selected = "selected"</if>>管理员</option>
						</select>
						<else />
							<if condition="$user['category_id'] == 1">管理员<else />员工</if>
						</if>
					</div>
				</div>
				<div class="form-group department">
					<label for="name" class="col-sm-2 control-label">部门</label>
					<input id="departments" name="department_id" type="hidden" value="{$department_id.last}" />
					
					<volist name="department_list" id="vo" key="k">
						<div class="col-sm-3 dep{$k}">
							<select id="{$k}" class="form-control" onchange="changeRoleContent(this.value,this.id)">
								<option value="">请选择部门</option>
								<volist name="vo" id="temp">
									<option value="{$temp.department_id}" 
										<foreach name="department_id" item="ve" >
											<php>
												if($ve == $temp['department_id']) echo 'selected = "selected"';
											</php>
										</foreach>
										>{$temp.name}</option>
								</volist>
							</select>
						</div>
					</volist>
					
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">岗位</label>
					<div class="col-sm-3">
						<if condition="!session('?admin')">
							<volist name="position_list" id="temp">
								<if condition="$user['position_id'] eq $temp['position_id']">{$temp.name}</if>
							</volist>
						</if>
						<select id="position_id" name="position_id" class="form-control" >
							<option value="">请选择岗位</option>
							<if condition="session('?admin')">
								<volist name="position_list" id="temp">
									<option value="{$temp.position_id}" <if condition="$user['position_id'] == $temp['position_id']">selected = "selected"</if>>{$temp.name}</option>
								</volist>
							<else />
								<volist name="zz_un" id="zz">
									<option value="{$zz.position_id}">{$zz.name}</option>
								</volist>
						</if>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">员工状态</label>
					<div class="col-sm-3">
						<select  name="status" class="form-control" >
							<volist name="status" id="vo">
							<option value="{$key}" <if condition="$user['status'] == $key">selected = "selected"</if>>{$vo}</option>
							</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">员工类型</label>
					<div class="col-sm-3">
						<select  name="type" class="form-control" >
							<volist name="type" id="vo">
							<option value="{$key}" <if condition="$user['type'] == $key">selected="selected"</if>>{$vo}</option>
							</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">工作状态</label>
					<div class="col-sm-3">
						<select  name="work_status" class="form-control" >
							<volist name="work_status" id="vo">
							<option value="{$key}" <if condition="$user['work_status'] == $key">selected = "selected"</if>>{$vo}</option>
							</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">性别</label>
					<div class="col-sm-3">
						<label class="checkbox-inline"><input type="radio"  name="sex" value="1" <if condition="$user['sex'] eq 1">checked="checked"</if>/>男</label>
						<label class="checkbox-inline"><input type="radio"  name="sex" value="2" <if condition="$user['sex'] eq 2">checked="checked"</if>/>女</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">邮箱</label>
					<div class="col-sm-3">
						<input class="form-control" name="email" type="text" value="{$user.email}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">手机</label>
					<div class="col-sm-3">
						<input class="form-control" name="telephone" type="text" value="{$user.telephone}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">联系地址</label>
					<div class="col-sm-3">
						<textarea name="address" class="form-control" >{$user.address}</textarea>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">配备信息</label>
					<div class="col-sm-8"> 	
					  	<volist name="peibei" id="vo" key="k">
						   	<label class="checkbox-inline">
						   		<input name="peibei[]" type="checkbox" value="{$k}"
						   			<volist name="pbinfo" id="vos" >
									   <if condition="$vos == $k">checked="checked"</if>
									</volist>
						  	 	>  {$vo}
						   	</label>
					   	</volist>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">是否买保险</label>
					<div class="col-sm-4">
						<label class="checkbox-inline">
					      <input name="baoxian" type="radio" value="0" <if condition="$user.baoxian eq 0">checked</if>> 未买
					  	</label>
					  	<label class="checkbox-inline">
					      <input name="baoxian" type="radio" value="1" <if condition="$user.baoxian eq 1">checked</if>> 已买
					  	</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">工资银行卡号</label>
					<div class="col-sm-4">
						<input name="bankcard" class="form-control" placeholder="银行卡号，如：6222******" value="{$user.bankcard}">
					</div><span class="col-sm-3">默认建设银行</span>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">身份证</label>
						<div class="col-sm-4">
						<input name="sfzid" class="form-control" placeholder="请填写身份证号码！" value="{$user.sfzid}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">身份证图片上传</label>
					<div class="col-sm-4">
						
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
 						
					</div>
       			</div>
       			<div class="form-group">
					<label class="col-sm-2 control-label">头像图片上传</label>
					<div class="col-sm-4">
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
					</div>
       			</div>
       			<div class="form-group" id="upload_file">
					<label class="col-sm-2 control-label">其它图片</label>
					<div class="col-sm-4">
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
				        <input type="button" class="btn btn-primary btn-xs"  id="addcontractType" value="增加" />
					</div>
       			</div>
				
				<div class="form-group">
					
						<label class="col-sm-2 control-label">更改理由</label>
						<div class="col-sm-4">
							<textarea id="remark" name="remark" class="form-control" ></textarea><span class="color-red"><strong>*必填</strong></span>
						</div>
				
				</div>
				
				<div class="form-group">
					<label class="col-sm-2 control-label">图片展示</label>
					<volist name="userimg" id="imgvo" key="k">
						<a href="{$imgvo.src}" class="example-image-link" data-lightbox="example-set" title="点击查看大图"><img src="{$imgvo.src}" width="100" /></a>
					</volist>
				</div>

				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-3">
						<input name="submit" class="btn btn-primary" type="submit" value="保存"/>&nbsp;&nbsp;<input type="button" class="btn" value="取消" onclick="javascript:history.go(-1);"/>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
	$(function(){
		$('#addcontractType').click(function(){
		$(this).after('<input id="img_up" name="img_up[]" class="btn btn-info" type="file" /><input type="button" class="btn btn-xs deletecontractType" value="[删除]" />');
		});
		$('#upload_file').on('click','.deletecontractType',function(){
			$(this).prev().remove();
			$(this).remove();
		});
	
		$("form").submit(function(e){
		    if($('#remark').val()==''){
				alert('请输入更改理由!');
				$('#remark').addClass('redborder').select();
				return false;
			}
		  });
		
		
		$('#position_id').click(
			function(){
				department_id = $('#department').val();
				if(department_id == ''){
					alert('请先选择部门!');
				}
			}
		);
		
		$("#department option[value='{$user['department_id']}']").prop("selected", true);
		$("#position_id option[value='{$user['position_id']}']").prop("selected", true);
	});
	function changeRoleContent(department_id,gdid){
//		department_id = $('#department').val();
		if(department_id == ''){
//			$("#position_id").html('');
		}else{
			gdid=parseInt(gdid);
			chk3=$(".dep3 select").attr('id');
			chk2=$('.dep2 select').attr('id');
			if(chk3 && gdid==1){
				$(".dep3").remove();
			}
			gdid++;
			$(".dep"+gdid).remove();
//			alert(gdid);

			//获得下级目录
			getJson('{:U("hrm/Structure/getDeson","id=")}',department_id,'.department',gdid);
			$('#departments').val(department_id);
//			$.ajax({
//				type:'get',
//				url:'{:U("hrm/structure/getDepartmentPosition","id=")}'+department_id,
//				async:false,
//				success:function(data){
//					if(data){
//						options = '';
//						$.each(data, function(k, v){
//							options += '<option value="'+v.position_id+'">'+v.name+'</option>';
//						});
//						$("#position_id").html(options);
//					}else{
//						$("#position_id").html('');
//					}
//				},
//				dataType:'json'
//			});		
		}
	}
	function getJson(urls,department_id,ddiv,gdid){
		$.ajax({
			type:'get',
			url:urls+department_id,
			async:false,
			success:function(data){
				if(data){
					options = '';
					$.each(data, function(k, v){
						options += '<option value="'+v.department_id+'">'+v.name+'</option>';
					});
					$(ddiv).append('<div class="col-sm-2 dep'+gdid+'"><select id="'+gdid+'" class="form-control" onchange="changeRoleContent(this.value,this.id)"><option value="">请选择部门</option>'+options+'</select></div>');
				}else{
					$(ddiv).append('');
				}
			},
			dataType:'json'
		});
	}
</script>

<include file="Public:alert" />
<script src="/Plugin/lightbox2/dist/js/lightbox-plus-jquery.min.js"></script>
<include file="Public:footer" />